package com.ruoyi.project.system.controller;


import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.system.domain.CollegePaperAnswerDetail;
import com.ruoyi.project.system.service.ICollegePaperAnswerDetailService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 答题详情Controller
 * 
 * @author ruoyi
 * @date 2020-11-19
 */
@RestController
@RequestMapping("/system/detail")
public class CollegePaperAnswerDetailController extends BaseController
{
    @Autowired
    private ICollegePaperAnswerDetailService collegePaperAnswerDetailService;

    /**
     * 查询学校考试结果列表
     */
    @PreAuthorize("@ss.hasPermi('system:detail:list')")
    @GetMapping("/list")
    public TableDataInfo list(CollegePaperAnswerDetail collegePaperAnswerDetail)
    {
        startPage();
        List<Map<String,Object>> list = collegePaperAnswerDetailService.selectCollegePaperAnswerDetailList(collegePaperAnswerDetail);
        return getDataTable(list);
    }

    /**
     * 查询学校考试结果详情列表
     */
    @PreAuthorize("@ss.hasPermi('system:detail:list')")
    @GetMapping("/info")
    public TableDataInfo info(CollegePaperAnswerDetail collegePaperAnswerDetail)
    {
        startPage();
        List<Map<String,Object>> list = collegePaperAnswerDetailService.selectListinfo(collegePaperAnswerDetail);
        return getDataTable(list);
    }

//    /**
//     * 导出答题详情列表
//     */
//    @PreAuthorize("@ss.hasPermi('system:detail:export')")
//    @Log(title = "答题详情", businessType = BusinessType.EXPORT)
//    @GetMapping("/export")
//    public AjaxResult export(CollegePaperAnswerDetail collegePaperAnswerDetail)
//    {
//        List<CollegePaperAnswerDetail> list = collegePaperAnswerDetailService.selectCollegePaperAnswerDetailList(collegePaperAnswerDetail);
//        ExcelUtil<CollegePaperAnswerDetail> util = new ExcelUtil<CollegePaperAnswerDetail>(CollegePaperAnswerDetail.class);
//        return util.exportExcel(list, "detail");
//    }

    /**
     * 获取答题详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:detail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(collegePaperAnswerDetailService.selectCollegePaperAnswerDetailById(id));
    }

    /**
     * 新增答题详情
     */
    @PreAuthorize("@ss.hasPermi('system:detail:add')")
    @Log(title = "答题详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CollegePaperAnswerDetail collegePaperAnswerDetail)
    {
        return toAjax(collegePaperAnswerDetailService.insertCollegePaperAnswerDetail(collegePaperAnswerDetail));
    }

    /**
     * 修改答题详情
     */
    @PreAuthorize("@ss.hasPermi('system:detail:edit')")
    @Log(title = "答题详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CollegePaperAnswerDetail collegePaperAnswerDetail)
    {
        return toAjax(collegePaperAnswerDetailService.updateCollegePaperAnswerDetail(collegePaperAnswerDetail));
    }

    /**
     * 删除答题详情
     */
    @PreAuthorize("@ss.hasPermi('system:detail:remove')")
    @Log(title = "答题详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(collegePaperAnswerDetailService.deleteCollegePaperAnswerDetailByIds(ids));
    }
}
